﻿
using WebAssistant.BusinessLogic;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Assistant.Forms.Configuration
{
    public partial class FormSetLockScreenPassword : UIEditForm
    {
        public FormSetLockScreenPassword()
        {
            InitializeComponent();
 
        }

        private void FormSetLockScreenPassword_ButtonOkClick(object sender, EventArgs e)
        {
            string password = tb_Password.Text;
            string confirm_password = tb_ConfirmPassword.Text;
            if(password == confirm_password)
            {
                try
                {
                    var result =DataAccess.UpdateSettingByKey("assistant.password", tb_Password.Text.Trim());
                    if(result == 1)
                    {
                        ShowSuccessTip("锁屏密码设置成功！");
                       
                    }
                    else
                    {
                        ShowErrorTip("锁屏密码设置失败！");
                    }
                    Close();
                }
                catch (Exception ex)
                {
                    ShowErrorDialog("错误：" + ex.ToString());
                }
            }
            else
            {
                ShowErrorTip("输入的密码不一致！");
            }
        }

        private void FormSetLockScreenPassword_ButtonCancelClick(object sender, EventArgs e)
        {
            Close();
        }
    }
}
